package com.lecture.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lecture.entity.LoadRateSummary;
import com.lecture.entity.LoadRateSummaryParam;
import com.lecture.mapper.LoadRateSummaryMapper;
import com.lecture.service.ILoadRateSummaryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 负荷率合计 服务实现类
 * </p>
 *
 * @author luyn
 * @since 2025-03-14
 */
@Service
public class LoadRateSummaryServiceImpl extends ServiceImpl<LoadRateSummaryMapper, LoadRateSummary> implements ILoadRateSummaryService {

    @Override
    public List<LoadRateSummary> getLoadRateSummaryList(LoadRateSummaryParam param) {
        QueryWrapper<LoadRateSummary> queryWrapper = new QueryWrapper<>();

        /*if (Func.isNotEmpty(param.getNhUnit1AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit1AvgLoadMax())) {
            queryWrapper.between("nh_unit1_avg_load", param.getNhUnit1AvgLoadMin(), param.getNhUnit1AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit1AvgLoadMin())) {
            queryWrapper.gt("nh_unit1_avg_load", param.getNhUnit1AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit1AvgLoadMax())) {
            queryWrapper.lt("nh_unit1_avg_load", param.getNhUnit1AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhUnit2AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit2AvgLoadMax())) {
            queryWrapper.between("nh_unit2_avg_load", param.getNhUnit2AvgLoadMin(), param.getNhUnit2AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit2AvgLoadMin())) {
            queryWrapper.gt("nh_unit2_avg_load", param.getNhUnit2AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit2AvgLoadMax())) {
            queryWrapper.lt("nh_unit2_avg_load", param.getNhUnit2AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhUnit3AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit3AvgLoadMax())) {
            queryWrapper.between("nh_unit3_avg_load", param.getNhUnit3AvgLoadMin(), param.getNhUnit3AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit3AvgLoadMin())) {
            queryWrapper.gt("nh_unit3_avg_load", param.getNhUnit3AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit3AvgLoadMax())) {
            queryWrapper.lt("nh_unit3_avg_load", param.getNhUnit3AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhUnit4AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit4AvgLoadMax())) {
            queryWrapper.between("nh_unit4_avg_load", param.getNhUnit4AvgLoadMin(), param.getNhUnit4AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit4AvgLoadMin())) {
            queryWrapper.gt("nh_unit4_avg_load", param.getNhUnit4AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit4AvgLoadMax())) {
            queryWrapper.lt("nh_unit4_avg_load", param.getNhUnit4AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhUnit5AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit5AvgLoadMax())) {
            queryWrapper.between("nh_unit5_avg_load", param.getNhUnit5AvgLoadMin(), param.getNhUnit5AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit5AvgLoadMin())) {
            queryWrapper.gt("nh_unit5_avg_load", param.getNhUnit5AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit5AvgLoadMax())) {
            queryWrapper.lt("nh_unit5_avg_load", param.getNhUnit5AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhUnit6AvgLoadMin()) && Func.isNotEmpty(param.getNhUnit6AvgLoadMax())) {
            queryWrapper.between("nh_unit6_avg_load", param.getNhUnit6AvgLoadMin(), param.getNhUnit6AvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhUnit6AvgLoadMin())) {
            queryWrapper.gt("nh_unit6_avg_load", param.getNhUnit6AvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhUnit6AvgLoadMax())) {
            queryWrapper.lt("nh_unit6_avg_load", param.getNhUnit6AvgLoadMax());
        }

        if (Func.isNotEmpty(param.getNhTotalAvgLoadMin()) && Func.isNotEmpty(param.getNhTotalAvgLoadMax())) {
            queryWrapper.between("nh_total_avg_load", param.getNhTotalAvgLoadMin(), param.getNhTotalAvgLoadMax());
        } else if (Func.isNotEmpty(param.getNhTotalAvgLoadMin())) {
            queryWrapper.gt("nh_total_avg_load", param.getNhTotalAvgLoadMin());
        } else if (Func.isNotEmpty(param.getNhTotalAvgLoadMax())) {
            queryWrapper.lt("nh_total_avg_load", param.getNhTotalAvgLoadMax());
        }

        if (Func.isNotEmpty(param.getBlAvgLoadMin()) && Func.isNotEmpty(param.getBlAvgLoadMax())) {
            queryWrapper.between("bl_avg_load", param.getBlAvgLoadMin(), param.getBlAvgLoadMax());
        } else if (Func.isNotEmpty(param.getBlAvgLoadMin())) {
            queryWrapper.gt("bl_avg_load", param.getBlAvgLoadMin());
        } else if (Func.isNotEmpty(param.getBlAvgLoadMax())) {
            queryWrapper.lt("bl_avg_load", param.getBlAvgLoadMax());
        }

        if (Func.isNotEmpty(param.getRecordDateMin()) && Func.isNotEmpty(param.getRecordDateMax())) {
            queryWrapper.between("record_date", param.getRecordDateMin(), param.getRecordDateMax());
        } else if (Func.isNotEmpty(param.getRecordDateMin())) {
            queryWrapper.gt("record_date", param.getRecordDateMin());
        } else if (Func.isNotEmpty(param.getRecordDateMax())) {
            queryWrapper.lt("record_date", param.getRecordDateMax());
        }*/


        return list(queryWrapper);
    }
}
